/**
 * 
 */
package org.pexx.rdm.utils;

import java.util.Calendar;
import java.util.Date;


/**
 * 
 */
public class RiftUtils {

//	
//	public static void main (String[] args) {
//		
//		Date gts = gameTimestampToDate(systemMillisToGameTime(System.currentTimeMillis()));
//				
//		System.out.println(gts);
//	}
	
	/**
	 * @param time
	 * @return
	 */
	public static Date gameTimestampToDate(int time) {

		Date date = Calendar.getInstance().getTime();

		int hs = time / 3600;
		int mn = (time - (3600 * hs)) / 60;
		int s = time - (3600 * hs + 60 * mn);

		date.setHours(hs);
		date.setMinutes(mn);
		date.setSeconds(s);

		return date;
	}
	
	public static int dateToGameTimestamp (Date date) {
		
		return gameTimeToTimestamp(date.getHours(), date.getMinutes(), date.getSeconds());
	}

	/**
	 * @param time
	 * @return
	 */
	public static String formatGameTimestamp(int time) {

		int hs, mn, s;

		hs = time / 3600;
		mn = (time - (3600 * hs)) / 60;
		s = time - (3600 * hs + 60 * mn);

		String hss, mns, ss;

		hss = hs < 10 ? "0" + hs : "" + hs;
		mns = mn < 10 ? "0" + mn : "" + mn;
		ss = s < 10 ? "0" + s : "" + s;

		return hss + ":" + mns + ":" + ss;
	}

	/**
	 * @param hour
	 * @param minute
	 * @param second
	 * @return
	 */
	public static int gameTimeToTimestamp(int hour, int minute, int second) {
		return  hour * 3600 + minute * 60 + second;
	}
	
	public static int currentSystemTime () {
		Date date = Calendar.getInstance().getTime();
		
		return date.getHours() * 3600 + date.getMinutes() * 60 + date.getSeconds();
	}

}
